/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年7月2日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.UserroleDao;
import org.scauinfo.fpos.service.UserroleService;
import org.scauinfo.fpos.vo.Userrole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 * 
 */
@Service
public class UserroleServiceImpl implements UserroleService {
	@Autowired
	private UserroleDao userroleDao;

	@Override
	public void saveUserrole(Userrole userrole) {
		userroleDao.save(userrole);
	}

	@Override
	public void updateUserrole(Userrole userrole) {
		userroleDao.update(userrole);
	}

	@Override
	public void deleteUserrole(int id) {
		Userrole userrole = userroleDao.get(id);
		userroleDao.delete(userrole);
	}

	@Override
	public List<Userrole> findAllUserrole(int page, int rows, String sort,
			String order) {
		return userroleDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return userroleDao.countAll();
	}

	@Override
	public boolean isExist(String userroleId) {
		boolean flag = false;
		String hql = "from Userrole as p where p.userroleId=" + userroleId;
		if (userroleDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public Userrole get(Serializable id) {
		return userroleDao.get(id);
	}

	@Override
	public List<Userrole> findAllUserrole() {
		return userroleDao.findAll();
	}

}
